var t = getApp();

Page({
    data: {
        events: [],
        activeNames: [],
        value: 3,
        calendarEvents: [],
        result: "",
        today: "",
        timeList: [],
        showCalendar: !0
    },
    onLoad: function(t) {
        this.setData({
            worker_id: t.worker_id
        }), this.getTime(), this.setData({
            today: new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate()
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    select: function(t) {
        console.log(t);
        var e = t.detail.work_date;
        this.setData({
            today: e
        }), this.getAppointment();
    },
    getTime: function() {
        var e = this, o = this, a = t.getNetAddresss("plugin.appointment.frontend.work-time.get-period-list");
        t._getNetWork({
            url: a,
            data: {
                worker_id: this.data.worker_id
            },
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    console.log(a.data);
                    var n = a.data, s = [];
                    n.forEach(function(t, e, o) {
                        s.push(t.work_date_format);
                    }), o.setData({
                        events: s
                    }), e.getAppointment(e.data.today);
                } else wx.showToast({
                    title: a.msg,
                    icon: "none"
                }), console.log(a.msg);
            }
        });
    },
    getAppointment: function(e) {
        var o = this, a = t.getNetAddresss("plugin.appointment.frontend.work-time.get-order-service-time-list");
        t._getNetWork({
            url: a,
            data: {
                worker_id: this.data.worker_id,
                work_date: this.data.today
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? o.setData({
                    timeList: e.data
                }) : (wx.showToast({
                    title: e.msg,
                    icon: "none"
                }), console.log(e.msg));
            }
        });
    }
});